import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        name: 'About',
        component: () => import('@/views/About.vue'),
        meta: { title: '活动首页' }
    },
    {
        path: '/coupon',
        name: 'Coupon',
        component: () => import('@/views/Coupon.vue'),
        meta: { title: '卡券' }
    },
    {
        path: '/card',
        name: 'Card',
        component: () => import('@/views/Card.vue'),
        meta: { title: '卡包' }
    },
    {
        path: '/poster',
        name: 'Poster',
        component: () => import('@/views/Poster.vue'),
        meta: { title: '专属海报' }
    },
    {
        path: '/business',
        name: 'Business',
        component: () => import('@/views/Business.vue'),
        meta: { title: '商务合作' }
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/Login.vue'),
        meta: { title: '核销登录' }
    },
    {
        path: '/writeoff',
        name: 'WriteOff',
        component: () => import('@/views/WriteOff.vue'),
        meta: { title: '卡券核销' }
    },
    {
        path: '/page_success',
        name: 'Page_success',
        component: () => import('@/views/PubInfo.vue'),
        meta: { title: '卡券核销' }
    },
    {
        path: '/pay_info',
        name: 'pay_info',
        component: () => import('@/views/PayInfo.vue'),
        meta: { title: '订单信息' }
    }
]

const Router = new VueRouter({
    // mode: 'history',
    mode: 'hash',
    routes
})

//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default Router
